/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * Projects
 * Copyright (C) Arnaud Duval 2010 <arnaud.duval@gmail.com>
 * 
 * Projects is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Projects is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _TRACK_POINT_HPP_
#define _TRACK_POINT_HPP_

#include <DateTime.hpp>
#include <libxml++/libxml++.h>
#include <fstream>

///@class TrackPoint
///@brief Defines a GPS point in GPX format
class TrackPoint
{
    public:
        ///@brief Default constructor
        TrackPoint();
        ///@brief Copy constructor
        TrackPoint(const TrackPoint&);
        ///@brief Constructor with arguments
        TrackPoint(double, double, double, double, DateTime);
        ///@brief Destructor
        ~TrackPoint();
        ///@brief Overload of = operator
        TrackPoint &operator=(const TrackPoint&);
        ///@brief Read data from a XML Node
        bool ReadXMLNode(xmlpp::Node*);
        ///@brief Write to XML file
        void WriteXML(std::ofstream &);
        ///@brief Write a part of the informations contained in the track point to the standard output (for debug purpose)
        void WriteForDebug();

        //Getters
        ///@brief Return latitude
        double GetLat();
        ///@brief Return longitude
        double GetLon();
        ///@brief Return time
        DateTime GetTime();
        ///@brief Return elevation value
        double GetElevation();
        ///@brief Return speed value
        double GetSpeed();

        //Setters
        ///@brief Set elevation value
        void SetElevation(double);
        ///@brief Set the speed value
        void SetSpeed(double);
        ///@brief Set the time value
        void SetTime(DateTime);
        ///@brief Set the latitude
        void SetLat(double);
        ///@brief Set the longitude
        void SetLon(double);


        

        ///@brief Compute the distance between two TrackPoint
        friend double Distance(TrackPoint, TrackPoint);
        ///@brief Overload of == operator
        friend bool operator==(const TrackPoint&, const TrackPoint&);
        ///@brief Overload of != operator
        friend bool operator!=(const TrackPoint&, const TrackPoint&);


    protected:

    private:
        ///@brief Latitude (in degrees)
        double lat;
        ///@brief Longitude (in degrees)
        double lon;
        ///@brief Elevation (in meters)
        double ele;
        ///@brief Speed (in m/s)
        double speed;
        ///@brief Time
        DateTime time;
};

#endif // _TRACK_POINT_HPP_
